﻿<UserControl x:Class="Workbench.Presentation.UserContols.ProcessWordsListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:uc="clr-namespace:Workbench.Presentation"
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="350">
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="boolToVis" />
    </UserControl.Resources>
    <DockPanel>
        <Grid DockPanel.Dock="Bottom" Margin="10" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
            </Grid.RowDefinitions>
            <Button Grid.Column="0" Content="« Prev" Command="{Binding PrevPageCommand}" Padding="5 0"></Button>
            <StackPanel Grid.Column="1" HorizontalAlignment="Center" Orientation="Horizontal">
                <TextBlock Margin="0 0 5 0">Page</TextBlock>
                <TextBox Margin="0 0 5 0" Width="30" Text="{Binding Path=CurrentPage}"></TextBox>
                <TextBlock Margin="0 0 3 0">of</TextBlock>
                <TextBlock Margin="0 0 3 0" Text="{Binding Path=TotalPages}"></TextBlock>
            </StackPanel>
            <Button Grid.Column="2" Content="Next »" Command="{Binding NextPageCommand}" Padding="5 0"></Button>
        </Grid>
        <DockPanel Margin="10" DockPanel.Dock="Top">
            <CheckBox Content="Hide Processed" IsChecked="{Binding ShouldHideProcessed}" DockPanel.Dock="Left"></CheckBox>
            <StackPanel DockPanel.Dock="Right" HorizontalAlignment="Right" Orientation="Horizontal">
                <TextBlock Margin="0 0 5 0">Show</TextBlock>
                <TextBox Width="30" Margin="0 0 5 0" Text="{Binding PageSize}"></TextBox>
                <TextBlock>per page</TextBlock>
            </StackPanel>
        </DockPanel>
        <ListBox VirtualizingPanel.IsVirtualizing="False" DockPanel.Dock="Top" SelectionMode="Extended" ItemsSource="{Binding CurrentWords}">
            <ListBox.Resources>
                <uc:ProcessWordsVisibilityConverter x:Key="Converter" />
            </ListBox.Resources>
            <ListBox.ItemContainerStyle>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="IsSelected" Value="{Binding IsSelected}" />
                    <Setter Property="Visibility">
                        <Setter.Value>
                            <MultiBinding Converter="{StaticResource Converter}">
                                <Binding Path="IsSet" />
                                <Binding RelativeSource="{RelativeSource AncestorType=ListBox}" Path="DataContext.ShouldHideProcessed" />
                            </MultiBinding>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ListBox.ItemContainerStyle>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="10"></ColumnDefinition>
                            <ColumnDefinition Width="*"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" Text="*" Visibility="{Binding Path=IsSet, Converter={StaticResource boolToVis}}"></TextBlock>
                        <TextBlock Grid.Column="1" Text="{Binding Content}"></TextBlock>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </DockPanel>
</UserControl>
